<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=
  , initial-scale=1.0"
    />
    <title>Document</title>
  </head>
  <body>
    <div id="test"></div>
    <div id="test1"></div>
    <div id="test2"></div>

    <script
      src="https://unpkg.com/react@16/umd/react.development.js"
      crossorigin
    ></script>
    <script
      src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"
      crossorigin
    ></script>
    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
  </body>
  <script type="text/babel">
    //创建组件
    class Time extends React.Component {
      state = { date: new Date() };
      componentDidMount() {
        setInterval(() => {
          this.setState({
            date: new Date(),
          });
        }, 1000);
      }
      render() {
        return (
          <div>
            <h1>hello</h1>
            <input type="text" />
            <span>现在是: {this.state.date.toTimeString()}</span>
          </div>
        );
      }
    }

    //渲染组件到页面
    ReactDOM.render(<Time />, document.getElementById("test"));
  </script>
</html>
